package com.igeek.boot.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.igeek.boot.anno.WMSLoganno;
import com.igeek.boot.entity.Incomingstock;
import com.igeek.boot.result.Result;
import com.igeek.boot.service.IIncomingstockService;
import com.igeek.boot.vo.PageQueryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jwj
 * @since 2023-12-26
 */
@RestController
@RequestMapping("/wisdom_factory/incomingstock")
@Api(tags = "入库表接口")
public class IncomingstockController {

    @Autowired
    private IIncomingstockService incomingstockService;


    //分页查询入库订单
    @ApiOperation("条件分页查询入库订单")
    @GetMapping("findPage")
    public Result findPage(@ApiParam("分页条件") PageQueryVO pageQueryVO){
        //查询入库订单
        Page<Incomingstock> page = incomingstockService.findPage(pageQueryVO);
        return new Result(true,"入库订单查询成功",page);
    }


    //查询所有的入库订单信息

    //修改入库订单
    @WMSLoganno(module = "入库订单",operation = "修改入库信息")
    @ApiOperation("修改入库订单")
    @PutMapping("/updateIncomingStockInfo")
    public Result updateIncomingStockInfo(@ApiParam("入库订单信息") @RequestBody Incomingstock incomingstock){
        //修改入库订单信息
        Boolean flag = incomingstockService.updateById(incomingstock);
        if(flag){
            return new Result(true,"修改成功");
        }else{
            return new Result(false,"修改失败");
        }
    }

    //添加入库订单信息
    @WMSLoganno(module = "入库订单",operation = "添加入库信息")
    @ApiOperation("添加入库订单信息")
    @PostMapping("/addIncomingStockInfo")
    public Result addIncomingStockInfo(@ApiParam("入库订单信息") @RequestBody Incomingstock incomingstock){
        //添加入库订单信息
        Boolean flag = incomingstockService.addIncomingStockInfo(incomingstock);
        if(flag){
            return new Result(true,"添加成功");
        }else{
            return new Result(false,"添加失败");
        }
    }

    //确认入库操作
    @WMSLoganno(module = "入库订单",operation = "执行入库操作")
    @ApiOperation("确认入库操作")
    @PostMapping("/confirmIncomingStock")
    public Result confirmIncomingStock(@ApiParam("入库订单信息") @RequestBody Incomingstock incomingstock){
        //添加入库订单信息
        Boolean flag = incomingstockService.confirmIncomingStock(incomingstock);
        if(flag){
            return new Result(true,"入库成功");
        }else{
            return new Result(false,"入库失败");
        }
    }


    //删除入库订单的信息
    @WMSLoganno(module = "入库订单",operation = "删除入库订单操作")
    @ApiOperation("删除入库订单的信息")
    @DeleteMapping("/delIncomingStock/{id}")
    public Result delIncomingStock(@PathVariable("id") Integer id){
        //删除入库订单信息
        boolean flag = incomingstockService.removeById(id);
        if(flag){
            return new Result(true,"删除成功");
        }else{
            return new Result(false,"删除失败");
        }
    }

}
